﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FlatRedBall;
using FlatRedBall.Math.Geometry;
using HarpoonMan.Utilities;

namespace HarpoonMan.WorldObjects
{
    class Door : Obstacle
    {
        private string _contentManagerName;
        private Sprite _sprite;
        private Sprite _sprite2;

        public bool Passable
        {
            get;
            set;
        }

        public Door(string contentManagerName)
            : base()
        {
            SpriteManager.AddPositionedObject(this);

            _sprite = SpriteManager.AddSprite(@"Content\Scenery\gateup");
            _sprite.AttachTo(this, false);
            _sprite.PixelScale();
            _sprite.ScaleX *= .5f;
            _sprite.ScaleY *= .5f;

            _sprite2 = SpriteManager.AddSprite(@"Content\Scenery\gatedown");
            _sprite2.AttachTo(this, false);
            _sprite2.PixelScale();
            _sprite2.Visible = false;
            _sprite2.ScaleX *= .5f;
            _sprite2.ScaleY *= .5f;

            Collision = ShapeManager.AddAxisAlignedRectangle();
            Collision.AttachTo(this, false);
            Collision.ScaleX = _sprite.ScaleX * .6f;
            Collision.ScaleY = _sprite.ScaleY * .6f;
            Collision.RelativeY = -4.0f;
            Passable = false;


            Collision.Visible = false;
        }

        public void Open()
        {
            _sprite.Visible = false;
            _sprite2.Visible = true;
            Passable = true;
        }

        public virtual void Destroy()
        {
            base.Destroy();
            SpriteManager.RemoveSprite(_sprite);
            SpriteManager.RemovePositionedObject(this);
        }
    }
}
